package net.framework.smc.kotlin.demokotlin.service

import net.framework.smc.kotlin.demokotlin.dao.UserRepository
import net.framework.smc.kotlin.demokotlin.po.ResultPo
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service


/**
 *  @authore zyx
 *  @date 2018/7/5 11:06
 */
@Service
class UserService {

    @Autowired
    lateinit var userRepository : UserRepository;



    fun login(params: Map<String, String>) : ResultPo {
        try {
            var userJpaDao = userRepository.findByUserName(params.get("userName").toString())
            if (userJpaDao.password.equals(params.get("password"))) {
                return ResultPo.success(userJpaDao)
            } else {
                return ResultPo.error("用户名或密码错误")
            }
        }catch (e : Exception) {
            return ResultPo.error("用户名或密码错误")
        }

    }

}
